package com.web.article;

import com.service.ArticleService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class DeleteArticleServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        ArticleService service=new ArticleService();

        try{
            String title=req.getParameter("title");
            service.delete(title);
            req.getRequestDispatcher("/ListArticle").forward(req, resp);

        }catch (Exception e){
            e.printStackTrace();

        }

    }
}
